<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1.传统的keyup按键弹起来的时候触发
        document.onkeyup = function () {
            console.log('我弹起来了');
        }

        // 2.提倡的keyup按键弹起来的时候触发
        document.addEventListener('keyup', function () {
            console.log('我弹起来了');
        })


        //3.onkeydown按下的时候触发
        document.addEventListener('keydown', function () {
            console.log('onkeydown我弹起来了');
        })

        //4.onkeypress 按键下的时候触发，不能识别功能键 CTRL shift,左右箭头
        document.addEventListener('keypress', function () {
            console.log('onkeypress我弹起来了');
        })
        //三个事件的执行顺序onkeydown，onkeypress，keyup




    </script>
</body>

</html>